/*
 * Copyright 2020-2021 redragon.dongbin
 *
 * This file is part of redragon-erp/赤龙ERP.

 * redragon-erp/赤龙ERP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.

 * redragon-erp/赤龙ERP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with redragon-erp/赤龙ERP.  If not, see <https://www.gnu.org/licenses/>.
 */
/**
 * @description GLCodeCombinationsDaoImpl.java
 * @author dongbin
 * @version 
 * @copyright
 */

package com.erp.common.account.dao.hibernate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.redragon.framework.hibernate.DaoSupport;
import org.redragon.framework.util.DaoCRUDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.erp.common.account.dao.GLCodeCombinationsDao;
import com.erp.common.account.dao.model.GLCodeCombinations;

/**
 * @description
 * @date 2021年2月5日
 * @author dongbin
 * 
 */
@Repository("glCodeCombinationsDaoCommon")
public class GLCodeCombinationsDaoImpl implements GLCodeCombinationsDao {
    
    //注入DaoSupport工具类
    @Autowired
    private DaoSupport daoSupport;

    @Override
    public List<GLCodeCombinations> getDataObjects(GLCodeCombinations paramObj) {
        String sql = "select c.* from gl_code_combinations c where c.status = 'Y'";
        
        Map<String, Object> args = new HashMap<String, Object>();
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment1", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment2", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment3", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment4", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment5", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment6", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment7", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment8", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment9", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment10", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment11", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment12", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment13", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment14", "and c.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "segment15", "and c.", args);
        sql = sql + " order by c.code_combination_id desc";
        
        Map<String, Class<?>> entity = new HashMap<String, Class<?>>();
        entity.put("c", GLCodeCombinations.class);
        
        return this.daoSupport.selectDataSql(sql, entity, args);
    }
    
    @Override
    public GLCodeCombinations getDataObject(String code) {
        String sql = "select c.* from gl_code_combinations c where c.code_combination_code = :code";
        
        Map<String, Object> args = new HashMap<String, Object>();
        args.put("code", code);
        
        Map<String, Class<?>> entity = new HashMap<String, Class<?>>();
        entity.put("c", GLCodeCombinations.class);
        
        List list = this.daoSupport.selectDataSql(sql, entity, args);
        if(list.size()>0) {
            return (GLCodeCombinations)list.get(0);
        }
        
        return null;
    }

}
